package com.nd.android.musicboxlibrary.business.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 库表封装
 * 
 * @author 慕容秋 (muroqiu@qq.com)
 */
public class MusicBoxDatabase extends SQLiteOpenHelper {
    private static final int VERSION = 2;

    /**
     * Creates a new instance of SQLiteDataHelper. <br>
     * Created 2014年9月15日 下午11:25:14
     * 
     * @param context
     *            上下文句柄
     * @param dbName
     *            数据库名称
     */
    public MusicBoxDatabase(Context context, String dbName) {
        super(context, dbName, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        switch ( oldVersion ) {
            case  1:
                db.execSQL( SQL_UPDATE_TABLE_VERSION_2 );
                break;
        }
    }

    /**
     * 数据库升级到版本2，新增音乐VIP信息表
     */
    private static final String SQL_UPDATE_TABLE_VERSION_2 = "CREATE TABLE IF NOT EXISTS VipInfo (" +
            "Uid LONG NOT NULL PRIMARY KEY," +
            "EndTime LONG NOT NULL DEFAULT -1," +
            "Intercepted INTEGER NOT NULL DEFAULT 0" +
            ")";
}
